const superagent = require("superagent");
module.exports = class weatherService {
  static getWeather(city) {
    return new Promise((resolve, reject) => {
      superagent
        .get("http://apis.juhe.cn/simpleWeather/query")
        .query({
          city,
          key: "8982e7f9d9cba9ea9dd3d6b066e1c252",
        })
        .end((err, res) => {
          if (err) reject(err);
          let data = JSON.parse(res.text);
          resolve(data);
        });
    });
  }
};
